package main

import (
	"fmt"

	"gitee.com/lzppppp/zabbix-api/cfg"
	"gitee.com/lzppppp/zabbix-api/internal"
)

func main() {

	// 通过用户名和密码，返回token
	jsonGetToken := cfg.PostDataJson{
		Jsonrpc: "2.0",
		Method:  "user.login",
		Params: cfg.Params{
			User:     "Admin",
			Password: "zabbix",
		},
		Id: 1,
	}

	Token := internal.AnalysisToken(internal.Post(jsonGetToken))

	// host get
	jsonHostGet := cfg.PostDataJson{
		Jsonrpc: "2.0",
		Method:  "host.get",
		Params: cfg.Params{
			Output:           []string{"hostid", "host"},
			SelectInterfaces: []string{"interfaceid", "ip"},
		},
		Id:   2,
		Auth: Token,
	}
	shuju := internal.Post(jsonHostGet)
	data12 := internal.AnalysisHost(shuju)
	fmt.Println(data12)

	// delete host
	// jsonDeleteHost := cfg.Data{
	// 	Jsonrpc: "2.0",
	// 	Method:  "host.delete",
	// 	Params: cfg.Params{
	// 		Hostids: []string{"10275"},
	// 	},
	// 	Id:   1,
	// 	Auth: Token,
	// }

	// deleteHostData := internal.Post(jsonDeleteHost)
	// fmt.Println(deleteHostData)

}
